package work;
import java.io.IOException;
import java.io.File;
import javax.servlet.*;
import javax.servlet.http.*;

public class WorkDownload extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException
	{
	
		String lista[], file;
		
		int index = Integer.parseInt(request.getParameter("index"));
		File list = new File(request.getSession().getServletContext().getRealPath("/workFolder/"));  
		lista = list.list();
		file = lista[index];
		
		request.setAttribute("workDownload", file);
		RequestDispatcher rd = request.getRequestDispatcher("trabalhos_link.jsp");
		rd.forward(request, response);
		
	
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
	{
		// same logic
		this.doGet(request, response);
	}
}
